package pt.iscte.pidesco.filebrowser.model;

import org.eclipse.core.runtime.IAdaptable;

public abstract class SourceElement implements IAdaptable {
	private final String name;
	private final PackageElement parent;

	public SourceElement(PackageElement parent, String name) {
		this.name = name;
		if(parent != null)
			parent.addChild(this);
		this.parent = parent;
	}
	
	public String getName() {
		return name;
	}
	
	public boolean isRoot() {
		return parent == null;
	}
	
	public boolean isPackage() {
		return this instanceof PackageElement;
	}
	
	public boolean isClass() {
		return this instanceof ClassElement;
	}
	
//	void setParent(PackageElement parent) {
//		this.parent = parent;
//	}
	
	public PackageElement getParent() {
		return parent;
	}
	
	public String toString() {
		return getName();
	}
	
	public Object getAdapter(Class key) {
		return null;
	}
}